class Http{
    
    request(url,method,data){
        return new Promise((resolve, reject) => {
            $.ajax({
                method:method,
                url:url,
                data:JSON.stringify(data),
                dataType: 'json',
                contentType:"application/json",
                success: function(response) {
                    console.log("成功")
                    resolve(response);  // 请求成功时，调用 resolve
                },
                error: function(xhr, status, error) {
                    console.error(xhr, status)
                    reject(new Error(error || 'Request failed'));  // 请求失败时，调用 reject
                }
            })
        })
    }
}